package com.xlf.service.base.controller.client;

import com.xlf.common.auth.dao.UserDetailsImpl;
import com.xlf.common.auth.util.SecurityUtils;
import com.xlf.common.core.annotation.Anonymous;
import com.xlf.common.core.annotation.RepeatSubmit;
import com.xlf.common.core.pojo.dto.JwtUserDetails;
import com.xlf.common.core.pojo.mode.AjaxResult;
import com.xlf.common.core.pojo.mode.BaseController;
import com.xlf.pojo.base.SysUserExtend;
import com.xlf.pojo.system.SysUser;
import com.xlf.service.base.config.RabbitMqConfig;
import com.xlf.service.base.pojo.dto.RegisterDTO;
import com.xlf.service.base.pojo.vo.UserInfoDTO;
import com.xlf.service.base.pojo.vo.UserInfoVO;
import com.xlf.service.base.service.SysUserExtendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author xlf 2734029211@qq.com
 * @Date 2024/1/6 16:20
 * @Description: TODO 用户信息
 * @Version 1.0
 */
@RestController
@RequestMapping("/base/user")
public class UserController extends BaseController {


    @Autowired
    SysUserExtendService sysUserExtendService;

    @Autowired
    RabbitMqConfig rabbitMqConfig;


    @Anonymous
    @GetMapping("/getUserInfo")
    public AjaxResult getUserInfo(){
        return success(sysUserExtendService.getUserInfoVO());
    }


    /**
     * 注册
     * @param registerDTO
     * @return
     */
    @RepeatSubmit(interval = 5000,message = "操作频繁，稍后重试！",ignoreParams = true)
    @Anonymous
    @PostMapping("/register")
    public AjaxResult register(@RequestBody  RegisterDTO registerDTO){
        sysUserExtendService.register(registerDTO);
        return success("注册成功！");
    }



    @Anonymous
    @GetMapping("/updateMQ")
    public AjaxResult updateMQ(){
        rabbitMqConfig.update();
        return success("更新成功！");
    }

    @PostMapping("/updateUserInfo")
    public AjaxResult updateUserInfo(@RequestBody UserInfoDTO userInfodto){
        sysUserExtendService.updateUserInfo(userInfodto);
        return success();
    }

    /**
     * 获取每个难度下的判题情况
     * @return
     */
    @Anonymous
    @GetMapping("/getJudgeInfo")
    public AjaxResult getJudgeInfo(){
        return success(sysUserExtendService.getJudgeInfo());
    }

    /**
     * 获取最近ac的题目
     * @return
     */
    @Anonymous
    @GetMapping("/getRecentlyACProblem")
    public AjaxResult getRecentlyACProblem(){
        return success(sysUserExtendService.getRecentlyACProblem());
    }


    /**
     * 获取热力图
     * @return
     */
    @Anonymous
    @GetMapping("/getHeatmap")
    public AjaxResult getHeatmap(){
        return success(sysUserExtendService.getHeatmap());
    }

}
